package com.example.bysj_sb.controller;

import com.example.bysj_sb.domain.authority.Role;
import com.example.bysj_sb.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
public class RoleController {
    //生成一个实例
    @Autowired
    private RoleService roleService;

    //添加
    @PostMapping("/role.ctl")
    //参数为一个对象
    public String add(@RequestBody Role role) {
        boolean added = roleService.add(role);
        if (added) {
            log.info("添加成功！");
            return "添加成功！";
        } else {
            log.info("添加失败！");
            return "添加失败！";
        }
    }
}